
#ifndef __OBJINST_H__
#define __OBJINST_H__

#include "ThreadObj.h"

template<class Type>
class CObjInst
{
public:
	static Type* Inst()
	{
		if (m_pInst != NULL)
			return m_pInst;

		//
		m_lock.Lock();
		m_pInst = new Type;
		m_lock.UnLock();

		return m_pInst;
	}

private:
	static CThreadLock	m_lock;
	static Type*		m_pInst;
};


template<class Type>
CThreadLock CObjInst<Type>::m_lock;

template<class Type>
Type*  CObjInst<Type>::m_pInst = NULL;

#endif
